package gold.digger;

import java.util.*;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC981 {
    public long startExecuteTime = System.currentTimeMillis();


    class TimeMap {
        Map<String, TreeMap<Integer, String>> map;

        public TimeMap() {
            map = new HashMap();
        }

        public void set(String key, String value, int timestamp) {
            if (!map.containsKey(key))
                map.put(key, new TreeMap());

            map.get(key).put(timestamp, value);
        }

        public String get(String key, int timestamp) {
            if (!map.containsKey(key)) return "";

            TreeMap<Integer, String> tree = map.get(key);
            Integer t = tree.floorKey(timestamp);//java 语言的骚操作
            return t != null ? tree.get(t) : "";
        }
    }


    public void run() {
        TimeMap solution = new TimeMap();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC981 an = new LC981();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
